package yijy.company;

import org.apache.commons.codec.binary.Base64;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * Created by yijy on 2017/6/8.
 */
public class test1 {
    public static void main(String[] args) {
        new test1().test();
    }

    public void base64Test(byte[] content ){
        String imgBase64 = new String(Base64.encodeBase64(content));
        System.out.println(imgBase64);
    }

    public void test(){
        try {
            String imgFile = "D:/搜狗高速下载/身份证正面.png";
            File file = new File(imgFile);
            byte[] content = new byte[(int) file.length()];
            FileInputStream finputstream = new FileInputStream(file);
            finputstream.read(content);
            finputstream.close();
            String imgBase64 = new String(Base64.encodeBase64(content));
            System.out.println(imgBase64);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
